package com.ylxn.codeTop;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Permute {

    public List<List<Integer>> permute(int[] nums) {
        List<Integer> integers = new ArrayList<>();
        ArrayList<List<Integer>> lists = new ArrayList<>();
        if (nums.length <= 1) {
            return lists;
        } else {
            for (int i = 0; i < nums.length; i++) {
                for (int j = 0; j < nums.length; j++) {
                    if (j!=i){
                        int temp = nums[i];
                        nums[i] = nums[j];
                        nums[j] = temp;
                    }
                }
            }
            for (int m = 0; m < nums.length; m++) {
                integers.set(m,nums[m]);
            }
        }
        lists.set(0,integers);
        return lists;
    }
}
